package com.lwg.vhr.service.impl;


import com.lwg.vhr.mapper.DepartmentMapper;
import com.lwg.vhr.model.Department;
import com.lwg.vhr.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentServiceImpl implements DepartmentService {


    @Autowired
    private DepartmentMapper departmentMapper;
    /**
     * @author: lwg
     * @Date: 2021/8/17 21:35
     * @Description: 获取所有的部门并以树的形式展示
     */
    @Override
    public List<Department> getAllDepartments() {
        return departmentMapper.getAllDepartmentsByParentId(-1);
    }

    @Override
    public void addDep(Department dep) {
        dep.setEnabled(true);
        departmentMapper.addDep(dep);
    }

    @Override
    public void deleteDepById(Department dep) {
        departmentMapper.deleteDepById(dep);
    }

    @Override
    public List<Department> getAllDepartmentsWithOutChildern() {
        return departmentMapper.getAllDepartmentsWithOutChildern();
    }
}
